<?php
// sunsblog.net blog.php (c)2004 Gjokica Zafirovski
require("include/session.inc");
require ("include/functions.inc");
require_once("verify_login.php"); //check if the user is logged in, include this one every access restricted page
include ("include/header.inc");
openConnection();
require ("include/navigation.inc");
?>
<tr>
<td valign="top" height="100%">
<?php
echo "<table width='400'><tr><td><p class='cetivo'>Блогирано на ".datum($date)."</p>";

$blogQuery = "SELECT title, content, user_id FROM sunsblogs WHERE blogDate = '$date'";

$blogResult = mysql_query($blogQuery);

if (mysql_numrows($blogResult) > 0) {
    while (list($title,$content,$user_id) =
	   mysql_fetch_row($blogResult)) {
	   $userQuery = "select ime, prezime, suns from sunsers where id='$user_id'";
	 $userResult = mysql_query($userQuery);
	 $userRow = mysql_fetch_array($userResult);
	 $ime = $userRow['ime'];
	 $prezime = $userRow['prezime'];
         if($userRow['suns'] == 2){
	   $ime = 'sunsblog';
	   $prezime ='';
	 }
	

    echo "<p class='cetivo'><b>$title</b><br>$content<br><span style='color:#B70004'>$ime&nbsp;$prezime</span></p>";
    }    
} else {    
    echo "<p class='cetivo'>Денес сеуште нема блог.</p>";
}
echo "</td></tr></table>";
?>

<form name="blog" action="postblog.php" method="POST">
<input type='hidden' name="user_id" value="<?php echo $IDtag[0] ?>" />
<table width="400">
<tr>
<td class="naslov" colspan="2">
 Постави нов блог за денеска:
</td>
</tr>
<tr>
<td class="cetivo">
Наслов:
</td>
<td width="100%">
<input type="text" name="naslov" style="display:block;width:100%;"/>
</td>
</tr>
<tr>
<td valign="top" class="cetivo">
Четиво:
</td>
<td>
<textarea name="cetivo" rows="10" style="display:block;width:100%;">
</textarea>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" name="submit" value="Блогиpај" />
</td>
</tr>
</table>
</form>
</td>
<?php
require ("include/blog.inc");
include ("include/footer.inc");
?>